"""
SQL模板相关底表
"""
from .model_base import *


class Templates(BaseTable):
    __database__ = "base"
    template_id = fields.IntField(pk=True, description="模板ID")
    template_title = fields.CharField(max_length=255, description="模板名称")
    template_desc = fields.CharField(max_length=255, description="模板描述")
    template_sql = fields.CharField(max_length=255, description="模板SQL")
    template_parm = fields.JSONField(description="引擎配置")
    template_engine_id = fields.CharField(max_length=255, description="执行引擎")

    class Meta:
        table = 'data_template'  # 数据库中的表名称
        table_description = 'SQL模板'


class TemplateTask(BaseTable):
    __database__ = "base"
    task_id = fields.IntField(pk=True, description="任务ID")
    template_id = fields.IntField(description="模板ID")
    task_parm = fields.JSONField(description="引擎配置")
    task_result = fields.CharField(max_length=255, description="任务结果")
    task_status = fields.CharField(max_length=255, description="任务状态")

    class Meta:
        table = 'data_template_task'  # 数据库中的表名称
        table_description = '模板任务'


class TemplateEngine(BaseTable):
    __database__ = "base"
    engine_id = fields.IntField(pk=True, description="任务ID")
    engine_name = fields.CharField(max_length=255, description="引擎名称")
    engine_config = fields.JSONField(description="引擎配置")

    class Meta:
        table = 'data_template_engine'  # 数据库中的表名称
        table_description = '模板执行引擎'
